package JET.UtilPanels;

import JET.Centers.ControlCenter;
import JET.Centers.Graphics.GUICenter;
import JET.MouseStuff.MouseMode;
import JET.MouseStuff.MouseSubMode;
import JET.MouseStuff.SpecialTasks.CreateSringBodyFace;
import JET.MouseStuff.SpecialTasks.JoinSpringBodiesByMassesTask;
import JET.MouseStuff.SpecialTasks.SaveSelectedInOrderMassesTask;
import JET.MouseStuff.Tasks.AddManyMassTask;
import JET.MouseStuff.Tasks.AddSingleMassTask;
import JET.MouseStuff.Tasks.AddSingleRSpringTask;
import JET.MouseStuff.Tasks.AddSingleSpringTask;
import JET.MouseStuff.Tasks.AddSingleWallTask;
import JET.MouseStuff.Tasks.CopySelectedItemsTask;
import JET.MouseStuff.Tasks.MoveMassesTask;
import JET.MouseStuff.Tasks.RotateTask;
import JET.MouseStuff.Tasks.SelectAllItemsTask;
import JET.MouseStuff.Tasks.SelectMassesInOrderTask;
import JET.MouseStuff.Tasks.SelectMassesTask;
import JET.MouseStuff.Tasks.SelectRSpringsTask;
import JET.MouseStuff.Tasks.SelectSpringsTask;
import JET.MouseStuff.Tasks.SelectWallsTask;
import JET.MouseStuff.Tasks.SetMoveableTask;
import JET.Scene;
import JET.mygui.UtilTabsPane.UtilTabsPaneTab;

/**
 *
 * @author 057Ry
 */
public class UPTools extends javax.swing.JPanel implements UtilTabsPaneTab {

    static final ControlCenter CC = ControlCenter.getInstance();

    private Scene scene;

    /** Creates new form UPTools */
    public UPTools() {
        initComponents();
    }

    public void setScene(Scene s) {
        scene = s;
    }

    public GUICenter.UtilTabs getId() {
        return GUICenter.UtilTabs.Tools;
    }

    public boolean isScrollable() {
        return false;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jButton22 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();

        setMaximumSize(new java.awt.Dimension(0, 0));
        setMinimumSize(new java.awt.Dimension(0, 0));
        setPreferredSize(new java.awt.Dimension(100, 37));
        setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Nut-32x32.png"))); // NOI18N
        jButton4.setToolTipText("Adds signle mass to active body");
        jButton4.setAlignmentX(0.5F);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setIconTextGap(0);
        jButton4.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        add(jButton4);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Many Nuts - 32x32.PNG"))); // NOI18N
        jButton5.setText("ManyMasses");
        jButton5.setToolTipText("Adds many masses to active body");
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        add(jButton5);

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Rshock-01-32x32.png"))); // NOI18N
        jButton9.setToolTipText("Adds spring connecting two masses of a body");
        jButton9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton9.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        add(jButton9);

        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Rshock-01-32x32.png"))); // NOI18N
        jButton15.setToolTipText("Adds spring connecting two masses of a body");
        jButton15.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton15.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });
        add(jButton15);

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Moveable - 32x32.PNG"))); // NOI18N
        jButton11.setToolTipText("Makes mass moveable or not");
        jButton11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton11.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        add(jButton11);

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/wall - 32x32.PNG"))); // NOI18N
        jButton10.setToolTipText("Adds wall connecting two masses of a body");
        jButton10.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton10.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        add(jButton10);

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/grab tool 32x32.png"))); // NOI18N
        jButton12.setToolTipText("Grab tool - selects all type items on scene");
        jButton12.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton12.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        add(jButton12);

        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/grab tool mass 32x32.PNG"))); // NOI18N
        jButton13.setToolTipText("Grab tool - selects masses");
        jButton13.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton13.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        add(jButton13);

        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/grab tool spring 32x32.PNG"))); // NOI18N
        jButton14.setToolTipText("Grab tool - selects springs");
        jButton14.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton14.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });
        add(jButton14);

        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/grab tool spring 32x32.PNG"))); // NOI18N
        jButton16.setToolTipText("Grab tool - selects springs");
        jButton16.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton16.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });
        add(jButton16);

        jButton17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/grab tool wall 32x32.PNG"))); // NOI18N
        jButton17.setToolTipText("Grab tool - selects walls");
        jButton17.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton17.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });
        add(jButton17);

        jButton18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/Move - 32x32.PNG"))); // NOI18N
        jButton18.setToolTipText("Moves single catched mass or multiple selected masses");
        jButton18.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton18.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        add(jButton18);

        jButton20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/scale tool 32x32.PNG"))); // NOI18N
        jButton20.setToolTipText("Scale tool");
        jButton20.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton20.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });
        add(jButton20);

        jButton19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/rotate tool 32x32.PNG"))); // NOI18N
        jButton19.setToolTipText("Rotates selected masses around choosed point in the scene");
        jButton19.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton19.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });
        add(jButton19);

        jButton21.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/copy tool 32x32.PNG"))); // NOI18N
        jButton21.setToolTipText("Copys selected objects into new body");
        jButton21.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton21.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });
        add(jButton21);

        jButton22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/join tool 32x32.PNG"))); // NOI18N
        jButton22.setToolTipText("Join tool - join many bodies into one");
        jButton22.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton22.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });
        add(jButton22);

        jButton23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/JET/Images/join tool 32x32.PNG"))); // NOI18N
        jButton23.setToolTipText("Join tool - join many bodies into one");
        jButton23.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton23.setPreferredSize(new java.awt.Dimension(37, 37));
        jButton23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton23ActionPerformed(evt);
            }
        });
        add(jButton23);

        getAccessibleContext().setAccessibleName("Tools");
    }// </editor-fold>//GEN-END:initComponents

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new AddSingleMassTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new AddManyMassTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton5ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new AddSingleSpringTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton9ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new AddSingleRSpringTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton15ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SetMoveableTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton11ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new AddSingleWallTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton10ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectAllItemsTask(scene));
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectMassesTask(scene));
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectSpringsTask(scene));
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton14ActionPerformed

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectRSpringsTask(scene));
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton16ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectWallsTask(scene));
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton17ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new MoveMassesTask() );
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton18ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
        CC.MC.setMouseMode(MouseMode.SCALE);
        CC.MC.setMouseSubMode(MouseSubMode.FIND_FIRST_OBJECT);
}//GEN-LAST:event_jButton20ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new RotateTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton19ActionPerformed

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new CopySelectedItemsTask());
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton21ActionPerformed

    private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectMassesInOrderTask(scene) );
        CC.MC.getMouseModeSequence().addTask( new SaveSelectedInOrderMassesTask(scene.EC.savedSelectionGroup1.getMassList(), scene) );
        CC.MC.getMouseModeSequence().addTask( new SelectMassesInOrderTask(scene) );
        CC.MC.getMouseModeSequence().addTask( new SaveSelectedInOrderMassesTask(scene.EC.savedSelectionGroup2.getMassList(), scene) );
        CC.MC.getMouseModeSequence().addTask( new JoinSpringBodiesByMassesTask(scene) );
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_jButton22ActionPerformed

    private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
        CC.MC.getMouseModeSequence().clear();
        CC.MC.getMouseModeSequence().addTask( new SelectMassesInOrderTask(scene) );
        CC.MC.getMouseModeSequence().addTask( new SaveSelectedInOrderMassesTask(scene.EC.savedSelectionGroup1.getMassList(), scene) );
        CC.MC.getMouseModeSequence().addTask( new CreateSringBodyFace(scene) );
        CC.MC.getMouseModeSequence().begin();
        CC.GUIC.repaintAllSceneTabs();

    }//GEN-LAST:event_jButton23ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton9;
    // End of variables declaration//GEN-END:variables

}
